package com.foolishbird.sdk.ui.fragment;

import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.foolishbird.sdk.core.HttpEngineApi;
import com.foolishbird.sdk.params.FloatGiftResponseParams;
import com.foolishbird.sdk.params.ResponseParams;
import com.foolishbird.sdk.params.bean.FloatGift;
import com.foolishbird.sdk.params.bean.State;
import com.foolishbird.sdk.utils.MyFragmentManger;
import com.foolishbird.sdk.utils.ResUtils;
import com.foolishbird.sdk.utils.WL;

import java.util.ArrayList;
import java.util.List;


public class FloatGiftSuccessFragment extends BaseHttpFragment implements View.OnClickListener {



    private TextView codeTxt,contentTxt,btnTxt;
    private ImageView backView;


    public static final FloatGiftSuccessFragment newInstance(Bundle bundle) {
        FloatGiftSuccessFragment fragment = new FloatGiftSuccessFragment();
        fragment.setArguments(bundle);
        return fragment;
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);
        int resource = ResUtils.getLayoutIdentifier(getActivity(), "fb_fragment_float_gift_info");
        View contentView =inflater.inflate(resource,null);
        backView = contentView.findViewById(getViewIdentifier("fb_float_close"));
        backView.setOnClickListener(this);
//        titleTxt = contentView.findViewById(getViewIdentifier("fb_fragment_float_title"));
//        titleTxt.setText("游戏礼包");
        codeTxt = contentView.findViewById(getViewIdentifier("float_gift_code"));
        contentTxt = contentView.findViewById(getViewIdentifier("float_gift_content"));
        btnTxt= contentView.findViewById(getViewIdentifier("float_gift_btn"));
        FloatGift gift = (FloatGift)getArguments().getSerializable("gift");
        codeTxt.setText(gift.getCardNo());
        contentTxt.setText(gift.getContent());
        btnTxt.setTag(gift.getCardNo());
        btnTxt.setOnClickListener(this);

        return contentView;

    }

    private List<FloatGift> newGiftList,recivedGiftList;



    @Override
    public void onClick(View view) {
        if(view ==backView){
            MyFragmentManger.getInstance().goBack(this);
        }else if(view ==btnTxt){
            //获取剪贴板管理器：
            ClipboardManager cm = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);

            String temp = (String)btnTxt.getTag();

            // 创建普通字符型ClipData
            ClipData mClipData = ClipData.newPlainText("Label", temp);
            // 将ClipData内容放到系统剪贴板里。
            cm.setPrimaryClip(mClipData);
            Toast.makeText(getContext(),"复制成功",Toast.LENGTH_SHORT).show();
        }

    }

}
